
const db = require('db');

module.exports = async ctx => {
    const { connection, run } = db.init();
    const id = ctx.params.id;
    try {
        await del(id, run);
        ctx.body = 'ok';
        ctx.status = 200;
    } catch (error) {
        ctx.status = 500;
        ctx.body = error
    }

    connection.end();
}

/** 删除 结算单 */
async function del(id, run) {
    const sql = `
        DELETE FROM clientInvoicingMessage 
        WHERE id=${id}
    `

    const result = await run(sql);
    if (result.err) {
        throw result.err
    }
}